package test1;

import java.util.Scanner;

public class test3 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入一个字符串");
        String str=sc.next();

        System.out.println("请输入你要查询的字符");
        String st=sc.next();

        int i=0;
        int length = st.length();
        int count=0;
        while (true){
            int i1 = str.indexOf(st, i);
            if (i1>=0){
                count++;
                i=i1+length;
            }else{
                break;
            }
        }
        System.out.println(st+"一共出现了"+count+"次");
    }
}
